﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls" 
    xmlns:UX="clr-namespace:DDU.UX;assembly=DDU.UX"
    xmlns:viewmodel="clr-namespace:DDU.ViewModel;assembly=DDU.ViewModel"
    xmlns:Converters="clr-namespace:DDU.Converters;assembly=DDU.Converters"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:telerikPrimitives="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Primitives"
    x:Class="DDU.Curriculum.MainPage"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="False">

    <phone:PhoneApplicationPage.Resources>
        <Converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
        <Converters:EnumTranslateConverter x:Key="EnumTranslateConverter"/>
        <Converters:NumberGreaterThanToVisibilityConverter x:Key="NumberGreaterThanToVisibilityConverter"/>
        <Converters:NumberEqualsParameterToVisibilityConverter x:Key="NumberEqualsParameterToVisibilityConverter"/>
        <Converters:StreamToImageConverter x:Key="StreamToImageConverter" />
    </phone:PhoneApplicationPage.Resources>

    <Grid x:Name="LayoutRoot">
        <Grid.Background>
            <ImageBrush Stretch="Fill" ImageSource="/Assets/back.png"/>
        </Grid.Background>
        <Grid.DataContext>
            <viewmodel:HomeViewModel/>
        </Grid.DataContext>
        
        <controls:Panorama>
            <controls:Panorama.Title>
                <Image Source="{Binding LogoPath}" Margin="12,76,0,0"/>
                <!--<TextBlock Text="{StaticResource IDS_APP_NAME}" Style="{StaticResource PhoneTextTitle1Style}" Foreground="{Binding PhoneThemeColor}" Margin="12,76,0,0"/>-->
            </controls:Panorama.Title>
            <controls:PanoramaItem Header="{StaticResource IDS_HOME_DASHBOARD}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>

                    <StackPanel Visibility="{Binding SemesterAvailable, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
                        <StackPanel>
                            <TextBlock Style="{StaticResource PhoneTextTitle2Style}" 
                                       Text="{StaticResource IDS_HOME_SEMESTER}"/>
                            <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" 
                                       Foreground="{StaticResource PhoneChromeBrush}">
								<Run Text="{Binding CurrentSemester.EducationLevel, Converter={StaticResource EnumTranslateConverter}}"/>
								<Run Text="{Binding CurrentSemester.Grade, Converter={StaticResource EnumTranslateConverter}}"/>
								<LineBreak/>
                                <Run Text="{Binding CurrentSemester.Year}"/>
								<Run Text="{StaticResource IDS_HOME_SCHOOL_YEAR}"/>
								<Run Text="{Binding CurrentSemester.Term, Converter={StaticResource EnumTranslateConverter}}"/>
                                <!--<LineBreak/>
                                <Run Text="{Binding CurrentSemester.StartTime}"/>-->
                            </TextBlock>
                        </StackPanel>
                        <StackPanel Margin="0,24,0,0">
                            <TextBlock Style="{StaticResource PhoneTextTitle2Style}" 
                                       Text="{StaticResource IDS_HOME_TODAY_COURSE}" 
                                       Visibility="{Binding TodaySchedulesCount, ConverterParameter=0, Converter={StaticResource NumberGreaterThanToVisibilityConverter}}"/>
                            <TextBlock Style="{StaticResource PhoneTextTitle2Style}" 
                                       Text="{StaticResource IDS_HOME_TODAY_NOCOURSE_MESSAGE}" 
                                       Visibility="{Binding TodaySchedulesCount, ConverterParameter=0, Converter={StaticResource NumberEqualsParameterToVisibilityConverter}, Mode=OneWay}"/>
                        </StackPanel>
                    </StackPanel>

                    <ListBox ItemsSource="{Binding TodaySchedules}" Grid.Row="1">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" 
                                           Margin="12" 
                                           Foreground="{StaticResource PhoneChromeBrush}">
									<Run Text="{Binding Name}"/>
									<LineBreak/>
									<Run Text="{Binding StartTime, StringFormat=\{0:HH:mm\}}"/>
									<Run Text=" - "/>
									<Run Text="{Binding EndTime, StringFormat=\{0:HH:mm\}}"/>
									<Run Text=" @ "/>
									<Run Text="{Binding RoomOrPlace}"/>
									<LineBreak/>
									<Run Text="{Binding Teacher}"/>
                                </TextBlock>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>

                    <TextBlock Text="{StaticResource IDS_HOME_IN_VACATIONS_MESSAGE}" 
                               VerticalAlignment="Center" 
                               Grid.RowSpan="2" 
                               Style="{StaticResource PhoneTextTitle3Style}" 
                               TextWrapping="Wrap" 
                               HorizontalAlignment="Center" 
                               Visibility="{Binding InVacation, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}"/>
                </Grid>
            </controls:PanoramaItem>
            <controls:PanoramaItem Header="{StaticResource IDS_HOME_BOOK_STORE}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>
                    <ListBox ItemsSource="{Binding Path=RecommendBooks}">
                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <toolkit:WrapPanel></toolkit:WrapPanel>
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <toolkit:HubTile Title="{Binding Preferential,StringFormat=\{0:C\}}" 
                                                 Margin="12,0,0,12"
                                                 Message="{Binding BookName}"
                                                 Source="{Binding Path=Stream, Converter={StaticResource StreamToImageConverter}}"
                                                 Tag="{Binding Path=Url}" 
                                                 Tap="GotoBookOnlinePage" />
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                    
                    <TextBlock Grid.Row="1"
                               Text="{Binding NetworkType, Mode=OneWay}"
                               Style="{StaticResource PhoneTextTitle3Style}"/>
                </Grid>
            </controls:PanoramaItem>
            <controls:PanoramaItem Header="{StaticResource IDS_HOME_MENU_HEADER}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>
                    <ScrollViewer>
                        <StackPanel>
                            <UX:UXTextMenu Content="{StaticResource IDS_HOME_MENU_COURSE_LIST}" Uri="/Views/CoursesView.xaml" />
                            <UX:UXTextMenu Content="{StaticResource IDS_HOME_MENU_SEMESTER}" Uri="/Views/SemesterView.xaml" />
                            <UX:UXTextMenu Content="{StaticResource IDS_HOME_MENU_VACATIONS}" Uri="/Views/VacationsView.xaml" />
                            <UX:UXTextMenu Content="{StaticResource IDS_HOME_MENU_EXAMINATIONS}" Uri="/Views/SemesterView.xaml" Visibility="Collapsed"/>
                            <UX:UXTextMenu Content="{StaticResource IDS_HOME_MENU_ACTIVITIES}" Uri="/Views/ActivitiesView.xaml" />
                            <UX:UXTextMenu Content="{StaticResource IDS_HOME_MENU_COURSEBOOKS}" Uri="/Views/BooksView.xaml" />
                            <UX:UXTextMenu Content="{StaticResource IDS_HOME_MENU_FICTIONS}" Uri="/Views/FictionsView.xaml" />
                            <UX:UXTextMenu Content="{StaticResource IDS_HOME_MENU_PREFERENCE}" Uri="/Views/PreferenceView.xaml" />
                            <UX:UXTextMenu Content="{StaticResource IDS_HOME_MENU_ABOUT_HELP}" Uri="/Views/AboutAndHelpView.xaml" />
                        </StackPanel>
                    </ScrollViewer>
                    
                    <StackPanel Grid.Row="1">
                        <UX:UXTextButton Foreground="{StaticResource PhoneBackgroundBrush}" 
                                         Content="{Binding ExamNotificationString, Mode=OneWay}"/>
                    </StackPanel>
                </Grid>
            </controls:PanoramaItem>
            
        </controls:Panorama>
    </Grid>

</phone:PhoneApplicationPage>